<?php
class T_Picupload extends T_Imageupload
{
	public static function getWidth($file)
	{
		$file = $_FILES['pic'];
		return $file['width'];
	}
	public static function getHeight($file)
	{
		$file = $_FILES['pic'];
		return $file['height'];
	}
	public static function  save_pic($file = '', $subpath= '', $name = '', $wh= array())
	{
		$path = '';   // 保护乱写图片文件夹
		if(empty($file))
		{
			$file = $_FILES['pic'];
		}
		else
		{
			$file = $_FILES[$file];
		}
		if(empty($path))
		{
			$path = get_image_path();
		}
		if(!empty($subpath))
		{
			$path .= $subpath;
		}
		$image_handle = new T_Imageupload();
		return $image_handle->save($file, $path, $name,$wh);
	}
	public static function getDir($name)
	{
		$md5=md5($name);
		$level = 2;
		$maxLevel=floor(strlen($md5)/2);
		if($level>$maxLevel)$level=$maxLevel;
		
		$dir="";
		for($i=0; $i<$level; $i++)
		{
			$first=substr($md5, $i, 1);
			$second=substr($md5, -($i+1), 1);
			$dir=$dir."/".$first.$second;
		}
		$dir = str_replace('ad','abc',$dir); 
		return $dir;  
	}
}
?>